import sys
sys.path.append("..")
from mri import *

fn=r'F:\PaperCode\lw\result\original_changeDataSet\Case16_result.mhd'
data0 = MRI(fn)

def usage():
    s = r'''usage:
    q---quit
    h---help
    s---set the filename
    >>starting....
    '''
    print(s)

usage()

while True:
    z,_,_ = data0.shape()
    print("shape is:",data0.shape())
    print("Input Z-coordinate:",(0,z-1))
    index = raw_input()
    if index == 'q':
        break
    if index == 'h':
        usage()
        continue
    if index == 's':
        sys.stdout.write('Input the filename:')
        fn = raw_input()
        data0 = MRI(fn)
        continue
    try:
        index = int(index)
        if index >= 0 and index < z:
            data0.displayZ(index)
        else:
            s = '!!!Warining:Z-coordinate should in[%d,%d]' %(0,(z-1))
            print(s)
    except Exception as err:
        usage()
        print(err)

